//
//  DailyDietDetailCell.m
//  SHHCPhone
//
//  Created by gfsh on 14-6-22.
//  Copyright (c) 2014年 sheng long. All rights reserved.
//

#import "DailyDietDetailCell.h"

@implementation DailyDietDetailCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        _circleIV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 16*3/2-14/2, 14, 14)];
        _circleIV.image = [UIImage imageNamed:@"菜品名称页-圆圈icon"];
        [self addSubview:_circleIV];
        _titleLab = [[UILabel alloc]initWithFrame:CGRectMake(21, 0, self.frame.size.width-14, 48)];
        _titleLab.textAlignment = NSTextAlignmentLeft;
        _titleLab.font = [UIFont systemFontOfSize:14];
        _titleLab.textColor = GET_COLOR(@"fe8cb6");
        _titleLab.numberOfLines = 0;
        [self addSubview:_titleLab];
        _contentLab = [[UILabel alloc]initWithFrame:CGRectMake(21, _titleLab.frame.origin.y+_titleLab.frame.size.height, self.frame.size.width-14, 0)];
        _contentLab.textAlignment = NSTextAlignmentLeft;
        _contentLab.font = [UIFont systemFontOfSize:13];
        _contentLab.textColor = GET_COLOR(@"3e3e3e");
        _contentLab.numberOfLines = 0;
        [self addSubview:_contentLab];
    }
    return self;
}

- (void)setCellFrame:(NSString*)content
{
    CGFloat cH = [self heightOfStr:content inSize:CGSizeMake(self.contentLab.frame.size.width,CGFLOAT_MAX) withFontSize:13];
    self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, 52+cH);
    self.contentLab.frame = CGRectMake(self.contentLab.frame.origin.x, self.contentLab.frame.origin.y, self.contentLab.frame.size.width, cH);
    self.contentLab.text = content;
}


- (CGFloat)heightOfStr:(NSString*)str inSize:(CGSize)size withFontSize:(CGFloat)fontSize
{
    return [str sizeWithFont:[UIFont systemFontOfSize:fontSize] constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping].height;
}

@end
